#include "ModelPostureLink.h"
#include "Model3D.h"
#include "Mesh.h"
#include "ModelPosture.h"
#include "ModelPostureBone.h"

ModelPostureLink::ModelPostureLink() {}
ModelPostureLink::ModelPostureLink(const ModelPostureLink&) {}
ModelPostureLink::~ModelPostureLink() {}

void ModelPostureLink::Initialize(Model3D* model, ModelPosture* posture)
{
	mModelPostureBonesCount = model->GetMeshesCount();
	mModelPostureBones = new ModelPostureBone*[mModelPostureBonesCount];
	for(int index = 0;index < mModelPostureBonesCount;index++)
	{
		Mesh* mesh = model->GetMeshByIndex(index);
		if(mesh == NULL)
		{
			mModelPostureBones[index] = NULL;
		}
		else
		{
			mModelPostureBones[index] = posture->GetModelPostureBoneByName(mesh->GetName());
		}
	}
}

XMFLOAT4X4 ModelPostureLink::GetTranformByMeshIndex(int pMeshIndex)
{
	return mModelPostureBones[pMeshIndex]->GetTransform();
}

ModelPostureBone* ModelPostureLink::GetModelPostureBoneByMeshIndex(int pMeshIndex)
{
	return mModelPostureBones[pMeshIndex];
}